package cn.com.springsource;

import cn.com.springsource.config.AppConfig;
import cn.com.springsource.dao.Dao;
import cn.com.springsource.dao.IndexDao;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.reflect.Proxy;

public class Test {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        //IndexDao dao = context.getBean(IndexDao.class);
        //Dao dao = context.getBean(IndexDao.class);

//        Dao dao = (Dao)context.getBean("indexDao");
//        //当EnableAspectJAutoProxy=false时,此处生成了动态代理对象,所以为false
//        System.out.println("instanceof IndexDao......"+(dao instanceof IndexDao));
//        //对了接口肯定是true的
//        System.out.println("instanceof Dao......" + (dao instanceof Dao));
//        //本身是个代理对象
//        System.out.println("instanceof Dao......"+(dao instanceof Proxy));
//        dao.query();
//        dao.queryStr("123");


        Dao dao1 = (Dao)context.getBean("orderDao");
        dao1.query();
        System.out.println(dao1);

    }
}
